fix(glm4_moe): load compressed-tensors NVFP4 expert checkpoints - #430
Open
gberasmus87 wants to merge 1 commit into
Open
fix(glm4_moe): load compressed-tensors NVFP4 expert checkpoints#430gberasmus87 wants to merge 1 commit into
gberasmus87 wants to merge 1 commit into
Conversation
glm4_moe is the only NVFP4 family that never learned the llm-compressor spelling. Its expert key pattern matches `weight | weight_scale | weight_scale_2` and its source spec sets neither `kind_map` nor `global_reciprocal`, so on a compressed-tensors export -- `gesong2077/GLM-4.5-Air-NVFP4`, whose experts are `weight_packed` + `weight_scale` + `weight_global_scale` -- the only tensors that match are the `weight_scale` ones, whose name the two dialects happen to share. The packed weights and the global scales are missed entirely, so the offload banks fill with scales and no weights. The machinery already exists; glm4_moe just is not wired to it. `Nvfp4ExpertSourceSpec.kind_map` folds `weight_packed` -> `weight` and `weight_global_scale` -> `weight_scale_2`, and `global_reciprocal` inverts the quant-side global scale at ingest -- without which the expert dequant is inverted and the model emits a single repeated token. glm5_next carries exactly this pair for its own compressed-tensors release; this mirrors it, including selecting the spec from `quant_method`. `input_global_scale` deliberately does not match: the routed-expert path is W4A16 and never quantizes activations. `detect_expert_quant` already recognises these exports, so `parse_config` needs no change -- `expert_quant` is `nvfp4` either way. The reader was the only gap. Verified on `gesong2077/GLM-4.5-Air-NVFP4` (compressed-tensors, config_groups num_bits=4 type=float group_size=16 strategy=tensor_group), against its real weight index: 69,120 routed-expert tensors, of which 17,280 are `input_global_scale`. Before, the spec matched 17,280 -- every one a `weight_scale`, no weights at all. After, it matches all 51,840 non-activation tensors, folding 17,280 `weight_packed` -> `weight` and 17,280 `weight_global_scale` -> `weight_scale_2`, and still rejects every `input_global_scale`. The modelopt path is untouched: an export without `quant_method == "compressed-tensors"` still gets the original spec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(glm4_moe): load compressed-tensors NVFP4 expert checkpoints
glm4_moe is the only NVFP4 family that never learned the llm-compressor spelling.
Its expert key pattern matches
weight | weight_scale | weight_scale_2and itssource spec sets neither
kind_mapnorglobal_reciprocal, so on acompressed-tensors export --
gesong2077/GLM-4.5-Air-NVFP4, whose experts areweight_packed+weight_scale+weight_global_scale-- the only tensors thatmatch are the
weight_scaleones, whose name the two dialects happen to share.The packed weights and the global scales are missed entirely, so the offload
banks fill with scales and no weights.
The machinery already exists; glm4_moe just is not wired to it.
Nvfp4ExpertSourceSpec.kind_mapfoldsweight_packed->weightandweight_global_scale->weight_scale_2, andglobal_reciprocalinverts thequant-side global scale at ingest -- without which the expert dequant is inverted
and the model emits a single repeated token. glm5_next carries exactly this pair
for its own compressed-tensors release; this mirrors it, including selecting the
spec from
quant_method.input_global_scaledeliberately does not match: the routed-expert path is W4A16and never quantizes activations.
detect_expert_quantalready recognises these exports, soparse_configneedsno change --
expert_quantisnvfp4either way. The reader was the only gap.Verified on
gesong2077/GLM-4.5-Air-NVFP4(compressed-tensors, config_groupsnum_bits=4 type=float group_size=16 strategy=tensor_group), against its real
weight index: 69,120 routed-expert tensors, of which 17,280 are
input_global_scale. Before, the spec matched 17,280 -- every one aweight_scale, no weights at all. After, it matches all 51,840 non-activationtensors, folding 17,280
weight_packed->weightand 17,280weight_global_scale->weight_scale_2, and still rejects everyinput_global_scale. The modelopt path is untouched: an export withoutquant_method == "compressed-tensors"still gets the original spec.